package com.varton.v3;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class CountTimeHandler implements MyInvocationHandler{

    private Object target;

    public CountTimeHandler(Object target) {
        this.target = target;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) {
        long start = System.currentTimeMillis();
        try {
            method.invoke(target,args);
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        }
        long end = System.currentTimeMillis();
        System.out.println("take time: "+(end - start)+"ms");
        return null;
    }
}
